//social database server
///BEGIN PHP PLATFORM ==========
#if defined(PLATFORM_PHP)
//use for developer mode 
#if DEVELOP_MODE
	//[server on viettel and use only for develeper] !very importance
#	if IS_RELEASE
#		define DBSERVER_URL "127.0.0.1"
#		define DBSERVER_PORT 11217
	//[server on local machine]
#	else
#		define DBSERVER_URL "127.0.0.1"
#		define DBSERVER_PORT 11215	
#	endif
//use for building release.
#else 
#	define DBSERVER_URL "127.0.0.1"
#	define DBSERVER_PORT 11212
#endif

//fb token database server
//use for developer mode 
#if DEVELOP_MODE
	//[server on viettel and use only for develeper] !very importance
#	if IS_RELEASE
#		define FBSERVER_URL "127.0.0.1"
#		define FBSERVER_PORT 11217
	//[server on local machine]
#	else
#		define FBSERVER_URL "127.0.0.1"
#		define FBSERVER_PORT 11214	
#	endif
//use for building release.
#else
#	define FBSERVER_URL "127.0.0.1"
#	define FBSERVER_PORT 11215
#endif

//access macro for social database server
#define DBOBJ	FunctionData::$static
#define DBCONNECT(handle) {if(!isset(handle) || handle==null){handle = new Memcache;handle->connect(DBSERVER_URL, DBSERVER_PORT) or die ("Could not connect");};}
#define DBGET(sv,key) sv->get(key)
#define DBSET(sv,key,data) {if(sv->get(key)==null)sv->set(key,data);else sv->replace(key,data);}
#define DBDEL(sv,key) sv->delete(key)
#define DBINC(sv,key) {if(sv->get(key)!=null)sv->increment(key);else sv->set(key,1);}
#define DBCLOSE(sv) {sv->close();sv = null;} 

//access macro for fb token database server
#define FB_DBOBJ	FunctionData::$fbdbconnect
#define FB_DBCONNECT() {if(!isset(FB_DBOBJ) || FB_DBOBJ==null){FB_DBOBJ = new Memcache;FB_DBOBJ->connect(FBSERVER_URL, FBSERVER_PORT) or die ("Could not connect to Facebook Token Database");};}
#define FB_DBGET(key) FB_DBOBJ->get(key)
#define FB_DBSET(key,data) {if(FB_DBOBJ->get(key)==null)FB_DBOBJ->set(key,data);else FB_DBOBJ->replace(key,data);}
#define FB_DBDEL(key) FB_DBOBJ->delete(key)
#define FB_DBINC(key) {if(FB_DBOBJ->get(key)!=null)FB_DBOBJ->increment(key);else FB_DBOBJ->set(key,1);}
#define FB_DBCLOSE() {FB_DBOBJ->close();FB_DBOBJ=null;}
#endif //PLATFORM_PHP
///END PHP PLATFORM ==========